package collectionexercise;

import java.util.ArrayList;
import java.util.Collection;

public class CollectionDemo2 {
    public static void main(String[] args) {
        Collection c=new ArrayList();
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("five");
        System.out.println(c);

        System.out.println("size:"+c.size());
        System.out.println("集合是否为空："+c.isEmpty());

        c.clear();
        System.out.println(c);
        System.out.println("size:"+c.size());
        System.out.println("集合是否为空"+c.isEmpty());

        Collection c2=new ArrayList();
        c2.add(new Point(1,2));
        c2.add(new Point(3,4));
        c2.add(new Point(5,6));
        c2.add(new Point(7,8));

        Point p=new Point(9,20);
        System.out.println(c2.contains(p));//false

        Point p1=new Point(1,2);
        System.out.println(c2.contains(p1));//true

        c2.remove(p1);
        System.out.println(c2);//[(3,4),(5,6),(7,8)]

        Point p3=new Point(4,8);
       p3.setX(100);
       c2.add(p3);
        System.out.println(c2);//集合是元素的引用，修改元素的值，集合的值也改变了
        System.out.println(p3);









    }
}
